package com.example.dto;

import com.example.entity.enums.CouponGetEnum;
import com.example.entity.enums.CouponTypeEnum;
import com.example.entity.enums.PromotionsScopeTypeEnum;
import com.example.util.DateUtils;
import com.example.validate.annotations.EnumValid;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

@Data
@ApiModel(description = "优惠券表单数据")
public class CouponFormDTO {

    @ApiModelProperty("优惠券id，新增不需要添加，更新必填")
    private Long id;

    @ApiModelProperty("优惠券名称")
    @NotNull(message = "优惠券名称不能为空")
    @Size(max = 20, min = 4, message = "优惠券名称长度错误")
    private String couponName;

    @ApiModelProperty("优惠券可以使用的开始时间")
    @DateTimeFormat(pattern = DateUtils.DEFAULT_DATE_TIME_FORMAT)
    @Future(message = "优惠券可以使用时间必须晚于当前时间")
    private LocalDateTime startTime;

    @ApiModelProperty("优惠券可以使用的结束时间")
    @DateTimeFormat(pattern = DateUtils.DEFAULT_DATE_TIME_FORMAT)
    @Future(message = "优惠券可以使用时间必须晚于当前时间")
    private LocalDateTime endTime;

    @ApiModelProperty("店铺ID,如果是0代表平台券")
    private Long storeId;

    @ApiModelProperty("店铺名称")
    private String storeName;
    @ApiModelProperty("优惠券类型[0->免费领取；1->活动领取；]")
    private CouponGetEnum couponType;

    @ApiModelProperty("折扣门槛，0代表无门槛")
    private Integer minPoint;


    @ApiModelProperty("优惠券类型，0：满减，1：折扣，2：无门槛")
    @NotNull(message = "优惠券折扣类型不能为空")
    @EnumValid(enumeration = {0,1,2})
    private CouponTypeEnum couponCategory;


    @ApiModelProperty("折扣值，满减填抵扣金额；打折填折扣值：80标示打8折")
    private Integer reduceAmount;


    @ApiModelProperty("最大优惠金额")
    private Integer maxDiscountAmount;


    @ApiModelProperty("活动描述")
    private String description;

    @ApiModelProperty("优惠券总量")
    @Range(max = 5000, min = 1, message = "优惠券总量必须在1~5000")
    private Integer publishCount;


    @ApiModelProperty("每人领取的上限")
    @Range(max = 10, min = 1, message = "每人限领数量必须在1~10")
    private Integer limitReceiveCount;


    @ApiModelProperty("优惠券范围关联的ID")
    private Long scopeId;

    @ApiModelProperty("关联范围类型:0全品类，1部分商品分类，2部分店铺分类，3指定商品")
    @NotNull(message = "优惠券关联类型不能为空")
    @EnumValid(enumeration = {0,1,2,3})
    private PromotionsScopeTypeEnum scopeType;
}